$(function()
{
	$("#btnLogin").click(login);
	
	var href = "register.jsp?json=" + json;
	$("#aRegister").attr("href", href);
});

login = function()
{
	var memberEmail = $("#txtMemberEmail").val();
	var memberPwd = $("#txtMemberPwd").val();
	var auto = $("#cbAuto").attr("checked") ? true : false; // 30天内自动登录

	if(!memberEmail || memberEmail == "邮箱账号" || !memberPwd)
	{
		$("#errorMsg").text("请输入正确的邮箱账号或密码");
		return;
	}
	
	var args = {memberEmail : memberEmail, memberPwd : memberPwd, auto : auto};
	
	var param = {reqData : args, reqUrl : "login"};
	
	ajaxRequest(param, function(returnData)
	{
		if(returnData.logined == "true")
		{
			$("#errorMsg").text("账号[" + memberEmail + "]已经登录,请先退出");
		}
		else if(returnData.hasMember == "true")
		{
			
			window.location = "index.jsp";
			
			if(json.playId)
			{
				json.memberId = returnData.memberId;
				window.location = "seat.jsp?json=" + $.toJSON(json);
			}
		}
		else
		{
			$("#errorMsg").text("请输入正确的邮箱账号或密码");
		}
	}, null);
}